<html>
 <head>
  <title>HAPI Search sample application</title>

  <script src=http://hapi.heuristscholar.org/load?v=02&key=ce1c992c139cfd5a6fdc77c5c71444925f229942></script>

  <script>
	function doSearch() {
	var mysearch = new HSearch(document.getElementById("search-string").value);

		var loader = new HLoader(	
			function(s,r) {
				displayResults(r);
			},
			function(s,e) {
				alert("load failed: " + e);
			});
		HeuristScholarDB.loadRecords(mysearch, loader);
	}

	function displayResults(r) {
		var div = document.getElementById("results");
		div.innerHTML = "";
		for (var i = 0; i < r.length; i++) {
			div.innerHTML += "<a href=\"http://heuristscholar.org/resource/" + r[i].getID() + "\">" + r[i].getTitle() + "</a><br/>";
	   }
	}
  </script>
 </head>

 <body>
  <h3>Search Heurist database</h3>
  <input type="text" id="search-string"></input>
  <input type="button" value="search" onclick="doSearch();"></input>
  <div id="results"></div>
 </body>

</html>
